enum PlayerCount {
  single(1),
  quad(4),
  six(6),
  nine(9);

  final int value;
  const PlayerCount(this.value);

  // 从整数值创建枚举
  factory PlayerCount.fromInt(int value) {
    return PlayerCount.values.firstWhere(
      (mode) => mode.value == value,
      orElse: () => PlayerCount.single,
    );
  }

  // 获取网格布局的行数和列数
  (int, int) get gridDimensions {
    switch (this) {
      case PlayerCount.single:
        return (1, 1);
      case PlayerCount.quad:
        return (2, 2);
      case PlayerCount.six:
        return (2, 3);
      case PlayerCount.nine:
        return (3, 3);
    }
  }

  int get row {
    switch (this) {
      case PlayerCount.single:
        return 1;
      case PlayerCount.quad:
      case PlayerCount.six:
        return 2;
      case PlayerCount.nine:
        return 3;
    }
  }

  int get column {
    switch (this) {
      case PlayerCount.single:
        return 1;
      case PlayerCount.quad:
        return 2;
      case PlayerCount.six:
      case PlayerCount.nine:
        return 3;
    }
  }

  int get maxVideoCount {
    return row * column;
  }
}